/**
 * vector thread
 */
#include <iostream>
#include <thread>
#include <vector>
#include <chrono>
#include <format>
#include <string>

std::string id2str(std::thread::id tid) {
    std::stringstream ss;
    ss << tid;
    return ss.str();
}

void do_work(int i) {
    using namespace std::chrono_literals;
    std::this_thread::sleep_for(1s);
    auto id = std::this_thread::get_id();
    std::cout << std::format("{}:do_work__:{}\n", id2str(id), i);
}

void do_work_i(int i) {
    using namespace std::chrono_literals;
    std::this_thread::sleep_for(std::chrono::seconds(i));
    auto id = std::this_thread::get_id();
    std::cout << std::format("{}:do_work_i:{}\n", id2str(id), i);
}

int main() {
    std::vector<std::thread> threads;
    for (int i = 0; i < 10; i++) {
        threads.emplace_back(do_work, i);
    }
    for (int i = 0; i < 10; i++) {
        threads.emplace_back(do_work_i, i);
    }
    for (auto &entry: threads) {
        entry.join();
    }
    return 0;
}